﻿using System;

namespace IBNet.DayTrade
{
   public static class RealTimeBarSecondsExtensions
   {
      /// <summary>
      /// Converts a RealTimeBarSeconds into a HistoricalBarSize.
      /// </summary> 
      public static HistoricalBarSize ConvertToHistoricalBarSize(
         this RealTimeBarSeconds realTimeBarSeconds)
      {
         HistoricalBarSize historicalBarSize;
         switch (realTimeBarSeconds)
         {
         case RealTimeBarSeconds.Five:
         historicalBarSize = HistoricalBarSize.FiveSeconds;
         break;
         case RealTimeBarSeconds.Fifteen:
         historicalBarSize = HistoricalBarSize.FifteenSeconds;
         break;
         case RealTimeBarSeconds.Thirty:
         historicalBarSize = HistoricalBarSize.ThirtySeconds;
         break;
         case RealTimeBarSeconds.Sixty:
         historicalBarSize = HistoricalBarSize.OneMinute;
         break;
         case RealTimeBarSeconds.OneHundredTwenty:
         historicalBarSize = HistoricalBarSize.TwoMinutes;
         break;
         case RealTimeBarSeconds.EighteenHundred:
         historicalBarSize = HistoricalBarSize.ThirtyMinutes;
         break;
         case RealTimeBarSeconds.ThirtySixHundred:
         historicalBarSize = HistoricalBarSize.OneHour;
         break;
         default:
         throw new ArgumentOutOfRangeException("realTimeBarSeconds");
         }
         return historicalBarSize;
      }
   }
}
